package com.xiyoo.cw.controller;


import com.xiyoo.cw.common.Result;
import com.xiyoo.cw.common.enums.ResultCode;
import com.xiyoo.cw.domain.task.CheckinRequest;
import com.xiyoo.cw.domain.task.TaskRequest;
import com.xiyoo.cw.service.TaskService;
import com.xiyoo.cw.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Objects;

/**
 * @Description:
 * @Date: 2025/5/13 10:33
 * @Author: zhouzhongqing
 */

@RestController
@RequestMapping("/api/task")
@Api(tags = "打卡相关")
@Slf4j
public class TaskController {

    @Resource
    private TaskService taskService;

    @ApiOperation(value = "立即打卡", notes = "立即打卡")
    @PostMapping("checkin")
    public Result<Object> checkin(@RequestBody @Valid CheckinRequest request) {
        if (Objects.isNull(request)) {
            return new Result<>(ResultCode.ERROR, "参数错误");
        }
        return taskService.checkin(request);
    }


    @ApiOperation(value = "任务状态", notes = "任务状态")
    @PostMapping("taskStatus")
    public Result<Object> taskStatus(@RequestBody @Valid TaskRequest request) {
        if (Objects.isNull(request)) {
            return new Result<>(ResultCode.ERROR, "参数错误");
        }
        return taskService.taskStatus(request);
    }


    @ApiOperation(value = "我的战绩详情", notes = "我的战绩详情")
    @GetMapping("details")
    public Result<Object> details() {
        return taskService.details();
    }

    @ApiOperation(value = "各任务打卡次数", notes = "各任务打卡次数")
    @GetMapping("taskCount")
    public Result<Object> taskCount() {
        return taskService.taskCount();
    }

}

